<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>通知管理列表</title>
    <link href="layui/css/layui.css" rel="stylesheet">
    <link href="static/css/style.css" rel="stylesheet">
    <script src="static/js/jquery.min.js"></script>
    <script src="static/js/jquery.cookie.js"></script>
    <script src="layui/layui.js"></script>
    <script src="static/js/base.js"></script>
    <script src="static/js/ax.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="static/js/html5.js"></script>
    <script src="static/js/respond.js"></script>
    <![endif]-->
</head>
<body class="bg_w">


<div class="layui-fluid">
    <div class="layui-card content-wrap">
        <!--查询-->
        <!--<div class="layui-form layui-card-header layuiadmin-card-header-auto">-->
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-sm4">
                        <label class="layui-form-label">公告标题</label>
                        <div class="layui-input-block">
                            <input type="text" id="noticeTitle" placeholder="请输入公告标题" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-sm4">
                        <label class="layui-form-label">公告内容</label>
                        <div class="layui-input-block">
                            <input type="text"  id="noticeContent" placeholder="请输入公告内容" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <!--<div class="layui-col-sm4">-->
                        <!--<label class="layui-form-label">发布人</label>-->
                        <!--<div class="layui-input-block">-->
                            <!--<input type="text" id="publisher" placeholder="请输入发布人" autocomplete="off" class="layui-input">-->
                        <!--</div>-->
                    <!--</div>-->
                    <div class="layui-col-sm4">

                        <a id="doSearch" class="layui-btn add_btn"><i class="layui-icon layui-icon-search"></i>搜索</a>
                        <button type="reset" class="layui-btn delete_btn"><i class="layui-icon layui-icon-delete"></i>清空</button>
                    </div>
                </div>
                <div class="layui-row layui-col-space10">
                    <!--<div class="layui-col-sm4">-->
                        <!--<label class="layui-form-label">发布时间起</label>-->
                        <!--<div class="layui-input-block">-->
                            <!--<input type="text" class="layui-input" id="fromTime" autocomplete="off">-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="layui-col-sm4">-->
                        <!--<label class="layui-form-label">发布时间至</label>-->
                        <!--<div class="layui-input-block">-->
                            <!--<input type="text" class="layui-input" id="toTime" autocomplete="off">-->
                        <!--</div>-->
                    <!--</div>-->


                </div>
            </div>
        </form>


        <!--数据列表展示-->
        <div>
            <!--<script type="text/html" id="optToolbar">-->
                <!--<div style="padding-bottom: 10px;">-->
                    <!--<button class="layui-btn layuiadmin-btn-useradmin add_btn" lay-event="viewNotice">查看</button>-->
                <!--</div>-->
            <!--</script>-->

            <table class="layui-hide" id="dataListTable"
                   lay-filter="active"></table>
        </div>


    </div>
</div>


</body>

<script>

    var table;
    var tableObj;

    layui.use(['table','form','laydate','layer','element'], function() {
        table = layui.table;
        var form = layui.form,
            layDateFrom = layui.laydate,
            layDateTo = layui.laydate,
            layer=layui.layer;

        // 初始化日期控件
        layDateFrom.render({
            elem: '#fromTime'
            // ,range: true
        });
        layDateTo.render({
            elem: '#toTime'
            // ,range: true
        });

        tableObj = ax.VTable({
            id: 'loadDataList',
            elem : '#dataListTable',
            url : schoolWebUrl + '/api/aos/notice/list',
            // toolbar: '#optToolbar',
            title:'通知列表',
            cols : [ [
                // {type : 'checkbox', fixed : 'left' },
                {type: 'numbers', width : 80, title : '序号', fixed : 'left'},
                {field : 'noticeTitle', title : '标题', minWidth : 200, fixed : 'left' },
                // {field : 'tipsTime', width : 200, title : '弹窗时间' },
                // {field : 'isTips', width : 100, title : '是否弹窗' },
                // {field : 'dispenseOrg', minWidth : 150, title : '权限' },
                {field : 'publisher', width : 80, title : '发布人' },
                {field : 'publishTime', width : 180, title : '发布时间'}
            ] ],
            done: function (res, curr, count) {
                $('.layui-table-body').find("table" ).find("tbody").children("tr").on('dblclick',function(){
                    var rowIndex = JSON.stringify($('.layui-table-body').find("table" ).find("tbody").find(".layui-table-hover").data('index'));
                    // var obj = res.data[rowIndex];
                    // window.location.href = 'preview.html?id=' + res.data[rowIndex];
                    top.layer.open({
                        type: 2,
                        title:"公告",
                        area: ['90%', '80%'],
                        fixed: true, //不固定
                        maxmin: true,
                        content: './preview.html?id=' + res.data[rowIndex].id
                    });
                });
            }

        });

        var $ = layui.$;

        $('#doSearch').on('click', function(){
            searchData();
        });

        //头工具栏事件
        // table.on('toolbar()', function(obj){
        //     var checkStatus = table.checkStatus(obj.config.id);
        //     switch(obj.event){
        //         case 'viewNotice':
        //             var data = checkStatus.data;
        //             if(data.length<=0) {
        //                 layer.open({
        //                     title: '信息提示'
        //                     ,content: '请选择查看的数据！'
        //                 });
        //                 break;
        //             }
        //             layer.open({
        //                 type: 2,
        //                 area: ['100%', '100%'],
        //                 fixed: true, //不固定
        //                 maxmin: true,
        //                 content: 'preview.html?id=' + data[0].id
        //             });
        //             break;
        //     };
        // });

    });

    function searchData() {
        //执行重载
        tableObj.reload({
            page : {
                curr: 1 //重新从第 1 页开始
            },
            where : {
                noticeTitle : $('#noticeTitle').val(),
                noticeContent : $('#noticeContent').val(),
                fromTime : $('#fromTime').val(),
                toTime : $('#toTime').val()
            }
        });
    }

</script>
</html>